Method for automatically determining document position in a scanner window

ABSTRACT

A method for determining the position of a document placed in the scanning widow of a flatbed scanner is disclosed. The method can correctly determine the precise position of a document from a pre-scanned image, including portions of a pressing cover (background color), illuminator (different color from the background) and the document. By color identification, a preliminary range having a rectangular area covering the document and the illuminator is first determined. Then, the colors of the four corners of the preliminary range are identified. Finally, the precise position of the document is determined by color identification, approaching from the rim of the preliminary range toward the the document.

BACKGROUND OF THE INVENTION

[0001] 1. Field of the Invention

[0002] The invention generally relates to an automatic method for a scanner, and more particularly relates to a method for determining the position of a document placed in the scanning widow of a flatbed scanner.

[0003] 2. Related Art

[0004] Automatic methods for a flatbed scanner to determine the position of a document placed on the scanner window are already well known. However, the prior methods are limited to the application of flatbed scanners that have a single background pattern of the scanner window. In other words, the prior method obtains a background image pattern of the scanner window by a pre-scanning process, then the background image pattern (a certain image color) can be omitted later from automatic ranged scanning so as to produce the document image only. When the prior method is applied to a flatbed scanner with two kinds (two colors) of background image pattern, incorrect determining of the document range may occur.

[0005] For example, beside a common black or white pressing cover for the flatbed, a conventional scanner may include an illuminator for lighting a transparency or a film for scanning. The illuminator has a color different from that of the pressing cover. Therefore, with the prior method the scanner mistakes the image of the illuminator as a part of the scanned document if only one background color (the color of the pressing cover) is considered. Or, a partial image of the scanned document is cropped if two background colors are considered.

SUMMARY OF THE INVENTION

[0006] The object of the invention is therefore to provide a method for determining the position of a document placed on a flatbed scanner in which the background image of the flatbed includes two color regions.

[0007] The method of the invention includes two steps for finding the scanned document. The first step is to locate a preliminary range of scanning. The preliminary range is determined from the rim toward the center of the scanner window. The preliminary range is a rectangular area covering the hardware (the illuminator) and the document located within the scanner window. The second step is to determine the portion of the document in the preliminary region by sampling certain points and comparing the relative position of the preliminary range to the center of the illuminator, then determining the precise position of the document by approaching the document in that portion through color identification.

[0008] Further scope of applicability of the invention will become apparent from the detailed description given hereinafter. However, it should be understood that the detailed description and specific examples, while indicating preferred embodiments of the invention, are given by way of illustration only, since various changes and modifications within the spirit and scope of the invention will become apparent to those skilled in the art from this detailed description.

BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The invention will become more fully understood from the detailed description given hereinbelow. However, this description is for purposes of illustration only, and thus is not limitative of the invention, wherein:

[0010]FIG. 1 is a hardware constructional view of a flatbed scanner;

[0011] FIGS. 2-1 to 2-5 are examples of scanned images of different sized documents placed in the scanner window;

[0012] FIGS. 3-1 to 3-7 are examples of scanned images with documents placed in different portions of the scanner window;

[0013]FIG. 4 is a flowchart showing the major steps of the invention;

[0014] FIGS. 5-1 to 5-5 are examples of preliminary ranges of scanning;

[0015]FIG. 6 is an example of locating a preliminary range of scanning;

[0016]FIG. 7 shows four reference points at the corners of a preliminary range of scanning;

[0017] FIGS. 8-1 to 8-28 are examples of relative positions between documents and the illuminator;

[0018] FIGS. 9-1 and 9-2 are examples of relative positions of documents to the center of the illuminator;

[0019] FIGS. 10-1 to 10-6 are examples of finding out the positions of documents in the preliminary regions.

DETAILED DESCRIPTION OF THE INVENTION

[0020] As shown in FIG. 1, a general flatbed scanner 10 includes a scanner window 10 that is usually transparent glass. A pressing cover 20 is removably mounted on the scanner window 10. On the pressing cover 20, at the surface facing the scanner window 10, there is an illuminator 21 for illuminating a transparency, film or the like, for the scanner to obtain an image. The illuminator 21 is usually located in the middle of the pressing cover 20, and has a certain position relative to the scanner window 10. The pressing cover 20 has a specific color, usually black or white, at the surface facing the scanner window 10. Meanwhile, the color of the illuminator 21 is different from that of the pressing cover 20, according to the construction and material thereof.

[0021] The size and position of a scanned document D relative to the scanner window 10 and the illuminator 21 influences the result of the automatic determining of document position. Firstly, an example is shown in FIGS. 2-1 to 2-3 in which three different sized documents D are placed under the illuminator 21. The sizes of the documents D are larger than, equal to and smaller than the size of the illuminator 21 in the three figures. In FIG. 2-1, the document D is larger than the illuminator 21 and is positioned to totally cover the range of the illuminator 21, so that only the background color of the pressing cover 20 is exposed on the rim of image of the document D. This is the simplest condition for which the aforesaid prior method can process automatic range-finding correctly. The same condition occurs in FIG. 2-2 that the document D is the same size as the illuminator 21 and is positioned right on the range of the illuminator 21. When the size of the document D is smaller than that of the illuminator 21, the position of the document D partially overlaps the illuminator 21 (as shown in FIG. 3-1), is totally free from the illuminator 21 (as shown in FIG. 3-7), or is fully enclosed in the range of the illuminator 21 (as shown in FIG. 2-3). In these cases, the scanned image includes the colors of the pressing cover 20, the illuminator 21 and the document D. The image with multiple background colors cannot be correctly processed by the prior method. Therefore, the invention intends to solve this problem and provides a method for determining finding the correct position of document D out of the complex background.

[0022] Even when the document D is larger than or the same size as the illuminator 21, it is still possible, as shown in FIGS. 2-4 and 2-5, by the position of the document D, that the scanned image includes colors of the pressing cover 20, the illuminator 21 and the document D, as described above.

[0023] The method for determining the position of document D in the scanned image with two background colors according to the invention is described below.

[0024] As with a conventional flatbed scanner, the scanner of the invention first pre-scans the scanner widow 10 with a document D placed thereon, and obtains a pre-scanned image that includes images of the pressing cover 20, the illuminator 21 and the document D. FIGS. 3-1 to 3-7 are examples of pre-scanned images in which the documents D are placed in different portions of the scanner window.

[0025] After obtaining the pre-scanned image, the invention processes the following steps to locate the position of the document D. The process is described in reference to the flowchart of FIG. 4. First, in step A, a preliminary range 1 of scanning is located. The preliminary range 1 is determined from the rim toward the center of the scanner window 10. The preliminary range 1 is an area covering the illuminator 21 and the document D located within the scanner window 10. Because the background color of the pressing cover 20 is a single one (black or white), the regions of the document D and the illuminator 21 can be determined by color identification, which will be described later. FIGS. 5-1 to 5-5 are examples of preliminary ranges 1 for different locations of document D relative to the illuminator 21.

[0026] Since most documents are rectangular in shape, in order to speed up the recognition process, the area of the preliminary ranges 1 is also preferably rectangular and a minimum one including images of the illuminator 21 and the document D. The process for obtaining the preliminary ranges 1 of FIGS. 5-1 to 5-5 is illustrated with FIG. 6, for example.

[0027] As shown in FIG. 6, to beginning from one side of the scanned image, searches along one axis (for example, the X-axis) of the X-Y coordinates to verify the color of the pixels on each column. If the pixels in the whole column with the same X-coordinate have the same color as the background color of the pressing cover 20, then the next column is searched until a column of pixels that includes a different color, for example at column X1, is located. Then a rim X1 of the document D or the illuminator 21 is obtained. It further searches the following columns until the column Xe, where the whole column pixels revert to the color of the pressing cover 20. Then the column X2 (=Xe−1), which is the column before Xe, is determined to be the other rim of the preliminary range 1.

[0028] Using the same process as above to search along the other axis (for example, the Y-axis) of the X-Y coordinates and verify the color of the pixels on each row, the rim rows of the preliminary range 1 in Y-axis, marked Y1 and Y2, can also be obtained. Therefore, the coordinates of four corners of the preliminary range 1 are P1(X1,Y2), P2(X2,Y2), P3(X2,Y1) and P4(X1,Y1). In other words, the four points enclose a minimum area covering the document D and the illuminator 21 as the preliminary range 1.

[0029] Steps B to E, as shown in FIG. 4, are used to determine the detailed position of the document D. In step B, the relationship between the document and the pressing cover 20 is encoded (converted into numerical codes). As shown in FIG. 7, the colors of the four corner points P1 to P4 of the preliminary range 1 are registered with numerical codes, so that “1” represents the same color as the pressing cover 20, and “0” represents a color different from that. Therefore, a serial number, like (0,0,0,1), indicates the position of the document D relative to the illuminator 21. FIGS. 8-1 to 8-28 are examples of the identification codes in accordance with the positional relationship between the document D and the illuminator 21.

[0030] The step C is to determine the positional relationship between the center point 211 of the illuminator 21 and the center point 10 of the preliminary range 1. Since the physical position of the illuminator 21 is fixed, we can use the origin point “O” of the coordinates of the scanner window as the origin of the center point 10 of the preliminary range 1 and the center point 211 of the illuminator 21 so that the position of the preliminary range 1 relative to the illustrator 21 can be identified. For example, the coordinates of the center 211 of the illuminator 21 can be expressed as (Xm, Ym); the center point 10 of the preliminary range 1 can be calculated as [(X2−X1)/2, (Y2−Y1)/2] from the corner coordinates thereof. The two points, as shown in FIGS. 9-1 and 9-2, can be used to determine the direction of the document D in the preliminary range 1.

[0031] Step D is to determine the direction of the document D in the preliminary range 1 for approaching the detailed position of the document D in the next step. The determination is based on the aforesaid identification codes of the document D and the illuminator 21 in the preliminary range 1, and the aforesaid coordinates of the centers 211, 10 of the illuminator 21 and the preliminary range 1. For example, in FIG. 9-1, the preliminary range 1 has an identification code of (0,1,0,0). The center point 10 of the preliminary range 1 is located at the right of the center point 211 of the illuminator 21. According to the positions of the four corners P1 to P4, the points P2 and P3 are located at the right side of the preliminary range 1. By referring to the values (1 and 0) of the points P2 and P3, we can judge that the document D is located at the lower right corner of the preliminary range 1 because P2=1 indicates that there is the background color of the pressing cover 20, and P3=0 indicates the existence of the document D. By the same process, the document D of FIG. 9-2 can be found at the upper left corner of the preliminary range 1.

[0032] FIGS. 8-1 to 8-4 show special positional relationships between the preliminary range 1 and the illuminator 21 in which the centers thereof overlap, and the identification codes are (0, 0, 0, 0) and (1, 1, 1, 1). In these conditions, the dimensions of the preliminary range 1 and the illuminator 21 have to be compared. In FIGS. 8-1 and 8-2, the identification codes are (0, 0, 0, 0), and the dimensions of the preliminary range 1 are the same as or larger than that of the illuminator 21. Therefore, the document D fully overlaps the preliminary range 1 or is smaller and is located in the center of the preliminary range 1. In FIGS. 8-3 and 8-4, the identification codes are (1, 1, 1, 1) and the width of the preliminary range 1 is larger or smaller than that of the illuminator 21. Therefore, the document D lies horizontally or vertically across the preliminary range 1.

[0033] Step E is to determine the precise position of the document D by searching the boundary of the document D from the rim of the preliminary range 1 in the direction toward the document D. For example, in FIG. 10-1, the identification code based on the four corners P1 to P4 is (0, 0, 0, 0). The length and width of the document D are smaller than that of the illuminator 21. Therefore, the document D is located in the middle of the preliminary range 1. The precise position of the document D can be determined by searching downward from the top edge, upward from the bottom edge, leftward from the right edge and rightward from the left edge of the preliminary range 1. When the pixels of the image in each row or column include two or more colors, the edge of document D in that direction is found. After this process, the image portions of the illuminator 21 in the preliminary range 1 are cropped, and the portion of the document D is obtained.

[0034] In FIG. 10-2, the identification code based on the four corners P1 to P4 is (1, 0, 1, 0). The center point 10 of the preliminary range 1 is located in the lower-left side of the center point 211 of the illuminator 21. Therefore, the document D is located in the lower-left corner of the preliminary range 1. The precise position of the document D can be determined by searching downward from the top edge and leftward from the right edge of the preliminary range 1 to locate the top and right edges of the document D. When the pixels of the image in the row or column include two or more colors, the edge of document D in that direction is found. After the top and right edges of the document D are obtained, the two edges and the left and bottom edges of the preliminary range 1 determine the position of the document D.

[0035] In FIG. 10-3, the identification code based on the four corners P1 to P4 is (1, 0, 0, 1). The center point 10 of the preliminary range 1 is located on the left side of the center point 211 of the illuminator 21. Therefore, the document D is located on the left side of the preliminary range 1. The precise position of the document D can be determined by searching downward from the top edge, upward from the bottom edge and leftward from the right edge of the preliminary range 1 to locate the top, bottom and right edges of the document D. When the pixels of the image in the row or column include two or more colors, the edge of document D in that direction is found. After the top, bottom and right edges of the document D are obtained, the three edges and the left edge of the preliminary range 1 determine the position of the document D.

[0036] In FIG. 10-4, the identification code based on the four corners P1 to P4 is (0, 1, 0, 0). The center point 10 of the preliminary range 1 is located on the right side of the center point 211 of the illuminator 21. Therefore, the document D is located on the lower-right corner of the preliminary range 1. The precise position of the document D can be determined by searching downward from the top edge and rightward from the left edge of the preliminary range 1 to locate the top and left edges of the document D. After the top and left edges of the document D are obtained, the two edges and the right and bottom edges of the preliminary range 1 determine the position of the document D.

[0037] In FIG. 10-5, the identification code based on the four corners P1 to P4 is (1, 0, 0, 1). The center point 10 of the preliminary range 1 is located on the right side of the center point 211 of the illuminator 21. Therefore, the document D is located on the right side of the preliminary range 1. The precise position of the document D can be determined by searching rightward from the left edge of the preliminary range 1 to find out the left edge of the document D. After the left edge of the document D is obtained, the left edge and the right, top and bottom edges of the preliminary range 1 determine the position of the document D.

[0038] In FIG. 10-6, the identification code based on the four corners P1 to P4 is (1, 1, 1, 1). The width of the preliminary range 1 is larger than the width of the illuminator 21. Therefore, the document D lies horizontally across the preliminary range 1. The precise position of the document D can be determined by searching downward from the top edge and upward from the bottom edge of the preliminary range 1 to locate the top and bottom edges of the document D. After the top and bottom edges of the document D are obtained, the two edges and the left and right edges of the preliminary range 1 determine the position of the document D.

[0039] As described above, the invention can correctly determine the precise position of a document from a pre-scanned image, including portions of the pressing cover, illuminator and the document.

[0040] The invention being thus described, it will be obvious that the same may be varied in many ways. Such variations are not to be regarded as a departure from the spirit and scope of the invention, and all such modifications as would be obvious to one skilled in the art are intended to be included within the scope of the following claims. 

What is claimed is:
 1. A method for automatically finding out the position of a document placed on a scanner from a pre-scanned image taken from the scanner window including portions of a background color, an illuminator and the document, comprising steps of: a) determining a preliminary range having a minimum rectangular area covering said illuminator and said document by searching from the rim toward the center of said prescanned image based on distinguishing from said background color; b) encoding the relationship between said document and said background color into an identification code by registering the colors of four corner points of said preliminary range that indicates whether said corners have the same color with said background color; c) finding out the positional relationship between a center point of said illuminator and a center point of said preliminary range; d) determining the direction of said document in said preliminary range; and e) finding out the detailed position of said document by searching the boundary of said document from the rim of said preliminary range in said direction toward said document.
 2. A method for automatically finding out the position of a document placed on a scanner according to claim 1 wherein said step of determining a preliminary range starts from one side of said pre-scanned image, searches along one axis of coordinates to verify the change of color of pixels on each line; then the same process on another axis of coordinates so as to get coordinates of four corners P1(X1,Y2), P2(X2,Y2), P3(X2,Y1) and P4(X1,Y1).
 3. A method for automatically finding out the position of a document placed on a scanner according to claim 2 wherein said process of searching along one axis of coordinates includes verifying along X-axis the change of color of pixels on each column till a column X1 of pixels that includes a different color; further searches till a column Xe of pixels that revert the same color, then the coordinate X2 equals to Xe−1.
 4. A method for automatically finding out the position of a document placed on a scanner according to claim 2 wherein said process of searching along one axis of coordinates includes verifying along Y-axis the change of color of pixels on each column till a row Y1 of pixels that includes a different color; further searches till a row Ye of pixels that revert the same color, then the coordinate Y2 equals to Ye−1.
 5. A method for automatically finding out the position of a document placed on a scanner according to claim 1 wherein said identification code for corner points of said preliminary range is encoded with “1” for the same color with said background color, and “0” for other colors different from said background color.
 6. A method for automatically finding out the position of a document placed on a scanner according to claim 1 wherein said positional relationship between a center point of said illuminator and a center point of said preliminary range is based on a same origin point of coordinates. 